package com.my.screenadapter.myActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.my.screenadapter.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LaunchActivity extends AppCompatActivity {

    @BindView(R.id.btn_A)
    Button btnA;
    @BindView(R.id.btn_B)
    Button btnB;
    @BindView(R.id.btn_C)
    Button btnC;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);
        ButterKnife.bind(this);
        if (savedInstanceState!=null){
            String string = savedInstanceState.getString(TAG);
            Log.i(TAG, "onCreate: "+string);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
        super.onSaveInstanceState(outState, outPersistentState);
        String string=TAG+" 被回收了 onSaveInstanceState";
        Log.i(TAG, "onSaveInstanceState: ");
        outState.putString(TAG,string);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        Log.i(TAG, "onRestoreInstanceState: ");
        if (savedInstanceState!=null){
            Log.i(TAG, "onRestoreInstanceState: "+savedInstanceState.getString(TAG));
        }
    }

    @OnClick({R.id.btn_A,R.id.btn_B,R.id.btn_C})
    protected void myClick(View v){
        Intent intent = new Intent(this, StandardActivity.class);
        switch (v.getId()){
            case R.id.btn_A:
                startActivity(intent);
                break;
            case R.id.btn_B:
                startActivityForResult(intent,100);
                break;
            case R.id.btn_C:
                startActivityForResult(intent,200);
                break;
        }

    }

    private static final String TAG = "LaunchActivity===";
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Log.i(TAG, "onActivityResult: "+requestCode+"---"+resultCode+"-----"+(data==null));
    }
}
